Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restructure #38

Merged
merged 43 commits into from
Nov 28, 2019
Merged

Restructure #38

merged 43 commits into from
Nov 28, 2019

Conversation

smoia
Copy link
Member

@smoia smoia commented Nov 21, 2019

Resolves #10 .
Address #23 , #1 .
After sharing some thoughts with @rmarkello , I'm reformatting the code so that we have an object to populate within interfaces scripts - each one to call based on the input.

@smoia
Copy link
Member Author

smoia commented Nov 25, 2019

Still working on phys2bids.py, but the rest should be ready.

@smoia smoia requested a review from rmarkello November 26, 2019 00:27
@eurunuela
Copy link
Collaborator

I would write list or numpy array so then we now what the can be. Especially because you're appending
stuff to var and this could be a source of conflicts.

The type of variable can be anything. We're using it in the code for lists, floats, ints, and strings at least. The only type it is not used for at the moment is tuples (we don't have many in the code) and numpy arrays. However, to avoid the possible conflict, the function is_valid is called on the token variable.
I added "any type", I don't think it makes sense to narrow it further in the docs.

Alright!

Copy link
Member

@rmarkello rmarkello left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @smoia ! Sorry for the delay in review—this was a lot to go through!

I had lots of thoughts (sorry), but one major point I'm a bit confused on is the difference between the blueprint_input and blueprint_output classes? From what I can tell they're largely similar in functionality, so I'm not sure the duplication is necessary!

Beyond that there's lots of little questions here and there, but I think if we settle on the class functionality in physio_obj.py then we can work on making that object a bit easier to work with. But that will come later—once this is merged and we have some tests added! 👍

Great start, though. Let me know if you have any questions about my questions / comments.

Comment on lines 24 to 27
if filename[-len(ext):] != ext:
filename = filename + ext

return file
return filename
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from pathlib import Path

def check_input_ext(filename, ext):
    return Path(filename).with_suffix(ext)

will do a lot of nice checks (e.g., confirm that ext is a valid suffix that starts with a dot, check if filename has a different suffix and strip it first). Might be worth using that instead? This will also make the below function (check_input_type()) a bit safer... See comment there.

Copy link
Member Author

@smoia smoia Nov 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will fail in the case of .nii.gz though (foreseeing application). We can use both?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually this will fail in any possible .*.gz, like .tsv.gz.

I'd like a safe solution for such cases.

Comment on lines +301 to +328
Properties - Input
------------------
timeseries : (ch x tps) :obj:`numpy.ndarray`
Numpy 2d array of timeseries
Contains all the timeseries recorded.
Impose same frequency!
freq : float
Shared frequency of the object.
Properties
ch_name : (ch) list of strings
List of names of the channels - can be the header of the columns
in the output files.
units : (ch) list of strings
List of the units of the channels.
start_time : float
Starting time of acquisition (equivalent to first TR,
or to the opposite sign of the time offset).

Methods
-------
return_index:
Returns the proper list entry of all the
properties of the object, given an index.
delete_at_index:
Returns all the proper list entry of the
properties of the object, given an index.
init_from_blueprint:
method to populate from input blueprint instead of init
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I'm getting what benefits this has over blueprint_input. The main differences (from what I can tell!) are that timeseries is required to be an array instead of a list of arrays, and this doesn't have a few of the methods that the blueprint_input does (e.g., .check_trigger_amount() and .rename_channels()). Could you clarify what purpose this class is serving over-and-above blueprint_input?

Copy link
Member Author

@smoia smoia Nov 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So here's the thing. For latter uses (e.g. if we go on with preprocessing or data analysis), I'd say numpy arrays are a bit easier to work with, rather than list of numpy arrays.
However, as the input might have different sampling rates, we need lists at the beginning to avoid issues with n/a or lengths.
Also, in input freq is a list and in output it's a float, and we need to really check this and be sure it's respected.

What would be a solution otherwise?

Co-Authored-By: Vicente Ferrer <[email protected]>
Copy link
Collaborator

@eurunuela eurunuela left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe some thorough testing should be done. Since we still have to work on the tests, and given that the package is still not compatible with some files, I'm accepting the PR. I'm aware of the possible issues that will raise with given file formats but I count on them being fixed once the testing is ready.

Copy link
Member

@rmarkello rmarkello left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with @eurunuela. Let's go ahead and merge this in, add some tests for the various utility functions, and re-address any bugs we find after.

@smoia smoia merged commit f2d7d52 into master Nov 28, 2019
@smoia smoia deleted the restructure branch November 28, 2019 13:54
@smoia smoia added the released This issue/pull request has been released. label Oct 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Help wanted Extra attention is needed Majormod This PR breaks compatibility, and increments the major version (+1.0.0) Refactoring Improve nonfunctional attributes released This issue/pull request has been released.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Split input in different outputs based on the sample frequency of the channels
4 participants